
var qSort = function(nums) {
    if (nums.length < 2) { return nums }

    // 寻找到中间数字
    var res = Math.floor(nums.length/2)
    // 将数组分开
    let mid = nums.splice(res,1)[0]

    let left = []
    let right = []
    // 
    for(let i = 0 ; i< nums.length ; i ++) {
        if(nums[i]<mid) {
            left.push(nums[i])
        }
        else {
            right.push(nums[i])
        }

    }
    return qSort(left).concat(mid,qSort(right))

}
let arr = [1,35,8,6,9]
let res = qSort(arr)
console.log(res);